/**
 * Created by leamiko on 2017/1/1.
 */

!function(window, $, miju) {

    // function KeyBoard (element, options) {
    //     this.$element = $(element);
    //     this.options = $.extend({}, KeyBoard.DEFAULTS, options || {});
    //     this.init();
    // }
    // KeyBoard.DEFAULTS = {
    //     disorder: false,
    //     title: '安全键盘'
    // };
    //
    // KeyBoard.prototype.init = function () {};
    //
    // KeyBoard.prototype.open = function () {};
    //
    // KeyBoard.prototype.close = function () {};
    //
    // KeyBoard.prototype.bindEvent = function () {};
    //
    // KeyBoard.prototype.unbindEvent = function () {};
    //
    // KeyBoard.prototype.fillPassword = function () {};
    //
    // KeyBoard.prototype.clearError = function () {};
    //
    // KeyBoard.prototype.error = function (mes) {};
    //
    // KeyBoard.prototype.backspace = function () {};
    //
    // KeyBoard.prototype.createNumsHtml = function () {};
    //
    // KeyBoard.prototype.createNums = function () {};
    //
    // KeyBoard.prototype.upsetOrder = function (arr) {};

    var DATA_KEY_KEYBOARD = 'miju.keyboard';

    var KeyBoard = miju.Class.extend({

        init: function(element, options) {
            this.$element = $(element);
            this.options = $.extend({}, KeyBoard.DEFAULTS, options || {});
            this.init();
        },

        open: function() {

        },

        close: function() {

        }
    });

    KeyBoard.DEFAULTS = {
        disorder: false,
        title: '安全键盘'
    };

    function Plugin(option) {
        var args = Array.prototype.slice.call(arguments, 1);

        return this.each(function () {

            var $this = $(this),
                keyboard = $this.data(DATA_KEY_KEYBOARD);

            if (!keyboard) {
                $this.data(DATA_KEY_KEYBOARD, (keyboard = new KeyBoard(this, option)));
            }

            if (typeof option == 'string') {
                keyboard[option] && keyboard[option].apply(keyboard, args);
            }
        });
    }

    miju.fn.keyBoard = Plugin;

}(window, Zepto, miju);
